package com.base.cn.platform.os.controller.qa.record;

import com.base.cn.platform.os.common.controller.BaseController;
import com.base.cn.platform.os.common.mybatis.Pagination;
import com.base.cn.platform.os.entity.manage.teacher.TeacherExpand;
import com.base.cn.platform.os.entity.qa.record.QaTeacherCommission;
import com.base.cn.platform.os.service.qa.record.QaTeacherCommissionBiz;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * 讲师收益Controller
 * @author LIZHIPENG
 * @since 2018/5/2
 */
@RestController
@RequestMapping("/course")
public class QaTeacherCommissionController extends BaseController {

    @Autowired
    private QaTeacherCommissionBiz teacherCommissionBiz;

    /**
     * 查询数量
     * @param commission 条件对象
     * @return 数量
     */
    @RequestMapping("/getCommissionCount")
    public BigDecimal getCommissionCount(@RequestBody QaTeacherCommission commission){
        return teacherCommissionBiz.getCount(commission);
    }
    /**
     * 查询问答讲师分成记录表（分页）
     * @param currentPage 页码
     * @param teacherCommission 条件
     * @param questionData 是否设置问题数据：true：是，false：否
     * @param userData 是否设置用户数据：true：是，false：否
     * @param teacherData 是否设置收益讲师数据：true：是，false：否
     * @return
     */
    @RequestMapping("/queryQaTeacherCommissionListPage")
    public PageInfo<QaTeacherCommission> queryQaTeacherCommissionListPage(@RequestParam(value = "currentPage", required = false, defaultValue = "1")int currentPage,
                                                                   @RequestBody QaTeacherCommission teacherCommission,
                                                                   @RequestParam("questionData")boolean questionData,
                                                                   @RequestParam("userData")boolean userData,
                                                                   @RequestParam("teacherData")boolean teacherData){
        Pagination page = new Pagination();
        page.setCurrentPage(currentPage);
        return teacherCommissionBiz.queryQaTeacherCommissionListPage(page, teacherCommission, questionData, userData, teacherData);
    }

    /**
     * 查询问答讲师分成
     * @return
     */
    @RequestMapping("/qaTeacherCommissionSum")
    public List<TeacherExpand> qaTeacherCommissionSum(@RequestParam("teacherId")BigDecimal teacherId){
        return teacherCommissionBiz.qaTeacherCommissionSum(teacherId);
    }


}
